package com.tikeyc.loveshare.adapter.home;

import android.content.Context;
import android.media.Image;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.tikeyc.loveshare.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by public1 on 2017/4/25.
 */

public class THomeAdapter {


    static public class GridViewAdapter extends BaseAdapter {

        private Context context;

        private int[] iconImages = new int[]{R.mipmap.nav_ico_car,R.mipmap.home_ico_xiche,R.mipmap.nav_ico_weixiu,
                                             R.mipmap.home_ico_wuliu,R.mipmap.nav_ico_banyun,R.mipmap.nav_ico_baomu};
        private String[] iconTexts = new String[]{"找司机","找乘客","家用帮手","买东西","卖东西","健康生活"};

        private class ViewHolder {
            ImageView imageView;
            TextView textView;
        }

        public GridViewAdapter(Context context) {
            this.context = context;

        }

        @Override
        public int getCount() {
            return iconImages.length;
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {

            ViewHolder viewHolder;
            if (view == null) {
                viewHolder = new ViewHolder();

                view = View.inflate(context, R.layout.home_fragment_gridview_item,null);
                viewHolder.imageView = (ImageView) view.findViewById(R.id.imageView);
                viewHolder.textView = (TextView) view.findViewById(R.id.textView);

                view.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder) view.getTag();
            }

            viewHolder.imageView.setImageResource(iconImages[i]);
            viewHolder.textView.setText(iconTexts[i]);

            return view;
        }
    }


    ////


    static public class ListViewAdapter extends BaseAdapter {

        private Context context;

        private class ViewHolder {
            ImageView imageView;
            TextView textView;
        }

        public ListViewAdapter(Context context) {
            this.context = context;
        }

        @Override
        public int getCount() {
            return 20;
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {

            ViewHolder viewHolder;
            if (view == null) {
                viewHolder = new ViewHolder();

                view = View.inflate(context, R.layout.home_fragment_listview_item,null);
                viewHolder.imageView = (ImageView) view.findViewById(R.id.imageView);
                viewHolder.textView = (TextView) view.findViewById(R.id.textView);

                view.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder) view.getTag();
            }

            return view;
        }
    }

}
